#include<bits/stdc++.h>
using namespace std;
int n,m,L,V,t,A[1005],d[10000],v,a[10000],cnt;
double b[10000];
int main()
{
        freopen("detect.in","r",stdin);
        freopen("detect.out","w",stdout);
        cin>>t;
        for(int z=1;z<=t;z++)
        {
           cin>>n>>m>>L>>V;
           for(int i=1;i<=n;i++)
           {
              cin>>d[i]>>v>>a[i];
              if(a!=0)
              {
                 b[i]=d[i]+(V*V-v*v)/(2*a[i]);
              }
              else if(v>V)
              {
                 b[i]=b[i];
              }
              else
              {
                 b[i]=L+1;
              }
           }
           for(int i=1;i<=m;i++)
           {
              cin>>A[i];
              for(int j=1;j<=n;j++)
              {
                 if(a[i]>=0)
                 {
                   if(A[i]>=b[i])
                   {
                     cnt++;
                   }
                 }
                 if(a[i]<0)
                 {
                   if(A[i]>=d[i]&&A[i]<=b[i])
                   {
                     cnt++;
                   }
                 }
              }
              
           }
           cout<<cnt<<endl;
        }
        return 0;
	
	   
}
